package com.telecomyt.jwportal.activity.register;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.widget.EditText;

import com.ruffian.library.widget.RTextView;
import com.telecomyt.jwportal.R;
import com.telecomyt.jwportal.activity.register.bean.RegisterBean;
import com.telecomyt.jwportal.base.BaseActivity;
import com.telecomyt.jwportal.utils.ToastUtils;

import butterknife.BindView;
import butterknife.OnClick;

public class RegisterActivity extends BaseActivity<RegisterPresenter> implements RegisterContract.View {

    @BindView(R.id.mEditUserName)
    EditText mEditUserName;
    @BindView(R.id.mEditPassWord)
    EditText mEditPassWord;
    @BindView(R.id.mEditaAginPassWord)
    EditText mEditaAginPassWord;
    @BindView(R.id.mBtnNotUseCoupon)
    RTextView mBtnNotUseCoupon;

    public static void start(Context context) {
        Intent starter = new Intent(context, RegisterActivity.class);
        context.startActivity(starter);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_register;
    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {

    }

    @Override
    protected RegisterPresenter creatPresenter() {
        return new RegisterPresenter(this);
    }


    @OnClick(R.id.mBtnNotUseCoupon)
    public void onViewClicked() {
        if (TextUtils.isEmpty(mEditUserName.getText().toString().trim())) {
            ToastUtils.showShort("请输入用户名");
            return;

        }
        if (TextUtils.isEmpty(mEditPassWord.getText().toString().trim())) {
            ToastUtils.showShort("请输入密码");
            return;

        }
        if (TextUtils.isEmpty(mEditaAginPassWord.getText().toString().trim())) {
            ToastUtils.showShort("请输入密码");
            return;
        }
        if (!mEditaAginPassWord.getText().toString().trim().equals(mEditPassWord.getText().toString().trim())) {
            ToastUtils.showShort("两次密码输入不一致");
            return;
        }
        persenter.toRegister(mEditUserName.getText().toString().trim(), mEditPassWord.getText().toString().trim(), mEditaAginPassWord.getText().toString().trim());
    }

    @Override
    public void regSuccess(RegisterBean bean) {
        ToastUtils.showShort("注册成功");
        finish();
    }
}